<template>
    <div>
        <ul>
            <li v-for="item of msgList" :key="item.id">
                <!-- params字符串写法 -->
                <!-- <router-link :to="`/home/message/detail/${item.id}/${item.title}`">{{item.title}}</router-link>&nbsp;&nbsp; -->
                <!-- paramsd对象写法  对象形式只能用name-->
                <router-link
                    :to="{
                        name: 'xiangqing',
                        query: {
                            id: item.id,
                            title: item.title,
                        },
                    }"
                    >{{ item.title }}</router-link
                >&nbsp;&nbsp;
                <button @click="pushShow(item)">push</button>
                <button @click="replaceShow(item)">replace</button>
            </li>
        </ul>
        <router-view></router-view>
    </div>
</template>
<script>
export default {
    name: "Message",
    data() {
        return {
            msgList: [
                { id: "001", title: "message001" },
                { id: "002", title: "message002" },
                { id: "003", title: "message003" },
            ],
        };
    },
    methods: {
        pushShow(m) {
            this.$router.push({
                name: "xiangqing",
                query: {
                    id: m.id,
                    title: m.title,
                },
            });
        },
        replaceShow(m) {
            this.$router.replace({
                name: "xiangqing",
                query: {
                    id: m.id,
                    title: m.title,
                },
            });
        },
    },
};
</script>

<style scoped>
</style>
